<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>
  <body>
    <!-- 求1+2!+3!+...+20!的值

2! 表示 2 的阶乘 2 * 1
3! 表示 3 的阶乘 3 * 2 * 1 -->

    <script>
      var res = 0;
      for (a = 1; a <= 20; a++) {
        var k = 1;
        for (j = 1; j <= a; j++) {
          k *= j;
        }
        res += k;
      }
      document.write(res);
    </script>
  </body>
</html>
